﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KnowlegeAssistant
{
    public partial class LoginForm : Form
    {

        private bool login = false;
        private User user = null;

        public LoginForm()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string user_name = this.username.Text.Trim();
            string user_pass = this.password.Text.Trim();
            this.login = LoginUtil.CheckLogin(user_name, user_pass);
            if (!this.login)
            {
                MessageBox.Show("Неправильный логин или пароль!");
            }
            else 
            {
                this.user = UserUtil.GetUser(user_name, user_pass);
                this.Close(); 
            }
        }

        public bool IsLogIn()
        {
            return this.login;
        }

        public User User
        {
            get { return this.user; }
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {

        }
    }
}
